package com.jianghu.dto;

import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Dto for the RecommendArticle
 * @author Administrator
 *
 */
public class RecommendArticle {
	public static DateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm");
	public static DateFormat baseFormat = new SimpleDateFormat("MM-dd hh:mm");
	public int id;
	public String title;
	public String summary;
	public URL from_icon;
	public String from;
	public boolean read;
	public boolean like;
	public int like_count;
	public int comment_count;
	public int category;
	public String created_at;
	
	public static String[] getFieldList(){
		return null;
	}
	
	public Date getCreatedDate(){
		return new Date();
	}
	
	public String getCreateAtString(){
		Date date = getCreatedDate();
		Date unixTime = new Date();
		if(date.getYear() == unixTime.getYear()){
			return baseFormat.format(date);
		}else{
			return format.format(date);
		}
	}
	public int getPastHours(){
		Date date = getCreatedDate();
		Date unixTime = new Date();
		long pastHours = (unixTime.getTime() - date.getTime()) / 3600000;
		return (int) pastHours;
	}
}
